package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.reggie.entity.SetmealDish;
import com.itheima.reggie.mapper.SetMealDishMapper;
import com.itheima.reggie.service.SetMealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class SetMealDishServiceImpl implements SetMealDishService {
    
    @Autowired
    private SetMealDishMapper mapper;
    
    /**
     * 添加套餐菜品数据
     *
     * @param setmealDish
     * @return
     */
    @Override
    public int add(SetmealDish setmealDish) {
        return mapper.insert(setmealDish);
    }
    
    /**
     * 根据套餐id来删除套餐菜品数据
     *
     * @param setmealId
     * @return
     */
    @Override
    public int deleteBySetmealId(long setmealId) {
        LambdaQueryWrapper<SetmealDish> qw = new LambdaQueryWrapper<>();
        qw.eq(SetmealDish::getSetmealId , setmealId);
        return mapper.delete(qw);
    }
}
